{

Parallax Propeller Servo Control Unit Test Program

Written by Daniel Harris (with special help from the ServoControllerSerial object)

A very short demonstration on how to control the PSCU to make it move a servo on P0

}
CON

  _clkmode = xtal1 + pll16x
  _clkfreq = 80_000_000

  PSCU_PIN  = 0      'the pin on the host propeller that the PSCU is connected to.
  PSCU_BAUD = 2_400

  
  P0    = 0                     'The P0 connector on the PSCU
  P1    = 1
  P2    = 2
  '  .
  '  .
  '  .
  P31   = 31



obj

  servo :       "ServoControllerSerial"


pub go | P0_pos, P0_ramp

  servo.START(PSCU_PIN, PSCU_BAUD)  'start the driver object for the PSCU -> ServoController

  P0_pos := 750                 'position to set the servo to (range = 500 -- 1000)
                                'servo position, 500 = 100% left, 750 = Centered, 1000 = 100% right

  P0_ramp := 32                 'servo ramp speed (the speed that the servo changes angle, range = 0 -- 63)
  
  servo.SETPOS(P0, P0_ramp, P0_pos)    'send command to PSCU to set the servo's position

  waitcnt(cnt + clkfreq * 5)    'wait 5 seconds

  P0_pos := 1000
  P0_ramp := 63

  servo.SETPOS(P0, P0_ramp, P0_pos)    'move thigns sloooooowly (63 ramp value)

  waitcnt(cnt + clkfreq * 10)    'wait 10 seconds

  P0_pos := 500
  P0_ramp := 0

  servo.SETPOS(P0, P0_ramp, P0_pos)    'move the servo quicklu (0 ramp value)                  


  repeat                        'end of the demo, nothing else to do, so do nothing forever

  